package com.kefu.call.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kefu.call.service.ActivityInventoryInfoService;
import com.kefu.call.vo.ActivityInventoryStatisticsVo;
import com.kefu.call.vo.ActivityUserInventoryStatisticsVo;
import com.kefu.common.annotation.Permission;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DetailVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

@Api(tags = "活动管理统计")
@RestController
@RequestMapping("call/activity/statistics")
public class ActivityStatisticsController extends AbstractBaseController {
    @Resource
    private ActivityInventoryInfoService activityInventoryInfoService;

    /**
     * 活动统计
     */
    @PostMapping("")
    @ApiOperation(value = "活动统计", notes = "活动统计")
    public Result<ActivityInventoryStatisticsVo> statistics(@Validated @RequestBody DetailVo search) {    
        logger.info("活动统计:{}", search);

        ActivityInventoryStatisticsVo result = activityInventoryInfoService.statistics(search);
        return ResultGenerator.genSuccessResult(result);
    }

    /**
     * 活动用户统计
     */
    @PostMapping("/userStatistics")
    @ApiOperation(value = "活动用户统计", notes = "活动用户统计")
    public Result<List<ActivityUserInventoryStatisticsVo>> userStatistics(@Validated @RequestBody DetailVo search) {    
        logger.info("活动用户统计:{}", search);

        List<ActivityUserInventoryStatisticsVo> result = activityInventoryInfoService.statisticsUserInventory(search);
        return ResultGenerator.genSuccessResult(result);
    }

    /**
     * 我的活动统计
     */
    @PostMapping("myStatistics")
    @ApiOperation(value = "我的活动统计", notes = "我的活动统计")
    public Result<ActivityInventoryStatisticsVo> myStatistics(@Validated @RequestBody DetailVo detail) {    
        logger.info("我的活动统计:{}", detail);
        ActivityInventoryStatisticsVo result = activityInventoryInfoService.myStatistics(detail);
        return ResultGenerator.genSuccessResult(result);
    }
}
